/*
* Powered By [choudou5]
* Web Site: http://www.hsolr.com
* License：MIT
* Since 2018 - 2020
*/
package com.choudou5.solr.service.event;

import com.choudou5.solr.annotation.ServiceInfo;
import com.choudou5.solr.bean.event.SolrEventPublishBean;
import com.choudou5.solr.framework.constants.SolrConsts;
import com.choudou5.solr.framework.constants.SysConsts;
import com.choudou5.solr.framework.holder.SysContextHolder;
import com.choudou5.solr.framework.util.UserUtil;
import com.choudou5.solr.service.BaseService;

import java.util.Date;

/**
 * @name 事件发布表 Service
 * @author choudou5
 * @date：2018-07-25
 */
@ServiceInfo(table = "solr_event_publish", desc = "事件发布表")
public class SolrEventPublishService extends BaseService<SolrEventPublishBean> {

    /**
     * 发布事件
     * @param eventType
     * @param paramJson
     */
    public void publish(SolrConsts.EventType eventType, String paramJson) {
        SolrEventPublishBean publishBean = new SolrEventPublishBean();
        publishBean.setEventKey(eventType.getKey());
        publishBean.setDesc(UserUtil.getUserName() + "-" + eventType.getDesc());
        publishBean.setParamJson(paramJson);
        publishBean.setProducer(SysContextHolder.getServiceHost());
        publishBean.setCreateTime(new Date());
        publishBean.setStatus(SysConsts.STATUS_N);
        add(publishBean);
    }

}